/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package BussinesLogic;

import DataAccess.Dao_Disciplina;
import DataModel.Disciplina;
import java.util.*;


public class BL_Disciplina {
    
    Dao_Disciplina dao_disciplina;

    public BL_Disciplina() {
        dao_disciplina = new Dao_Disciplina();
    }
    
    public Request registrarDisciplina(String nombre, String descripcion, String logo, String evento){
        
        nombre = nombre.toUpperCase();
        Request rqst = new Request();
        
        Disciplina disciplina = new Disciplina();
        disciplina.setNombre(nombre);
        disciplina.setDescripcion(descripcion);
        disciplina.setLogo(logo);
        
        rqst = dao_disciplina.registrarDisciplina(disciplina);
        if(!rqst.getTransac()) return rqst;
        
        rqst = dao_disciplina.registrarDisciplinaEvento(evento, nombre);
        if(!rqst.getTransac()) dao_disciplina.eliminarDisciplina(disciplina);
        
        return rqst;
        
    }
    
    public Request consultarDisciplinaPorEvento(String evento){
        
        Request rqst = dao_disciplina.consultarDisciplinaPorEvento(evento);       
        if(!rqst.getTransac()) return rqst;
        
        Vector v = (Vector) rqst.getObject();
        Vector vString = new Vector<String>(1,1);
        
        for(int i=0;i<v.size();i++){
            Disciplina d = (Disciplina) v.elementAt(i);
            vString.add(d.getNombre());
        }
        rqst.setTransac(true);
        rqst.setObject(vString);
        return rqst;
    }
    
      
    
}
